package com.hefu.virtuallife.ui.purchase.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.text.util.Linkify;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hefu.virtuallife.R;
import com.hefu.virtuallife.ui.purchase.bean.RouteInfo;


/**
 * 物流信息
 */
public class RouteItemAdapter extends BaseAdapter {
	
	private Context context;
	private List<RouteInfo> infos = new ArrayList<>();
	public RouteItemAdapter(Context context,List<RouteInfo> infos){
		this.context = context;
		this.infos = infos;
	}
	@Override
	public int getCount() {
		return infos.size();
	}
	@Override
	public Object getItem(int position) {
		return infos.get(position);
	}
	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		if(convertView == null){
			convertView = View.inflate(context, R.layout.view_route_item, null);
			holder = new ViewHolder();
			holder.icon = convertView.findViewById(R.id. iv_route_icon );
			holder.icon_top_line =  convertView.findViewById(R.id.icon_top_line);
			holder.icon_bottom_line =  convertView.findViewById(R.id.icon_bottom_line );
			holder.ll_bottom_line = convertView.findViewById(R.id.ll_bottom_line );
			holder.tv_content = convertView.findViewById(R.id.tv_content );
		    convertView.setTag(holder);
		}else {
			holder = (ViewHolder) convertView.getTag();
		}

		holder.icon.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_circle_yellow));
		holder.icon_top_line.setVisibility(View.VISIBLE);
		holder.icon_bottom_line.setVisibility(View.VISIBLE);
		holder.ll_bottom_line.setVisibility(View.VISIBLE);
		holder.tv_content.setText(infos.get(position).getInfo());

		return convertView;
	}

	 class ViewHolder{
		private ImageView icon;
		private View icon_top_line;
		private View icon_bottom_line;
		private LinearLayout ll_bottom_line;
		private TextView tv_content;
	}
}
